package top.ahwyy.controller.Action;

import java.io.UnsupportedEncodingException;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;

import top.ahwyy.controller.impl.cardImpl;
import top.ahwyy.controller.inter.card;

public class userReplyAction  implements ServletRequestAware, ServletResponseAware {

	public HttpServletResponse response;
	public HttpServletRequest request;
	public String content;
	public String forumId;
	public String uid;
	
	public String execute(){
		
		response.setContentType("text/html;charset=utf-8");
		try {
			request.setCharacterEncoding("utf-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		System.out.println(content+forumId+uid);
		
		if(content == null||forumId == null||uid == null ||content.equals(""))
			return "false";
		card ci = new cardImpl();
		boolean flag = ci.insertUserReply(content, new Integer(forumId), new Integer(uid));
		if(flag)
			return "success";
		return  "false";
	}

	@Override
	public void setServletResponse(HttpServletResponse arg0) {
		// TODO Auto-generated method stub
		this.response =  arg0;
	}

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		// TODO Auto-generated method stub
		this.request =  arg0;
	}
}
